﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Admin.aspx.cs" Inherits="Agricultural_Sales.ASP.Admin" %>

    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>特色农产品销售系统 - 管理后台</title>
        <style>
            * {
                margin: 0;
                padding: 0;
                box-sizing: border-box;
            }

            body {
                font-family: 'Microsoft YaHei', sans-serif;
                background-color: #f5f7fa;
                color: #333;
            }

            /* 顶部导航栏 */
            .top-header {
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                height: 60px;
                background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
                box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
                z-index: 1000;
                display: flex;
                align-items: center;
                justify-content: space-between;
                padding: 0 20px;
            }

            .logo-section {
                display: flex;
                align-items: center;
                gap: 15px;
            }

            .logo-icon {
                width: 40px;
                height: 40px;
                background: rgba(255, 255, 255, 0.2);
                border-radius: 8px;
                display: flex;
                align-items: center;
                justify-content: center;
                font-size: 20px;
                color: white;
            }

            .system-title {
                font-size: 20px;
                font-weight: 600;
                color: white;
                margin: 0;
            }

            /* 优化用户信息区域布局 */
            .user-info {
                display: flex;
                align-items: center;
                gap: 15px;
                color: white;
            }

            .welcome-text {
                font-size: 14px;
                color: rgba(255, 255, 255, 0.9);
            }

            .logout-btn {
                background: rgba(255, 255, 255, 0.1);
                border: 1px solid rgba(255, 255, 255, 0.3);
                color: white;
                padding: 8px 15px;
                border-radius: 5px;
                text-decoration: none;
                font-size: 13px;
                transition: all 0.3s ease;
                cursor: pointer;
            }

            .logout-btn:hover {
                background: rgba(255, 255, 255, 0.2);
                border-color: rgba(255, 255, 255, 0.5);
                text-decoration: none;
                color: white;
            }

            /* 管理员头像样式 */
            .admin-avatar {
                width: 40px;
                height: 40px;
                border-radius: 50%;
                overflow: hidden;
                border: 2px solid rgba(255, 255, 255, 0.3);
                background: rgba(255, 255, 255, 0.1);
                display: flex;
                align-items: center;
                justify-content: center;
                margin-right: 10px;
            }

            .avatar-img {
                width: 35px;
                height: 35px;
                border-radius: 50%;
                border: 2px solid rgba(255, 255, 255, 0.3);
                object-fit: cover;
                transition: all 0.3s ease;
            }

            .avatar-img:hover {
                border-color: rgba(255, 255, 255, 0.6);
                transform: scale(1.05);
            }

            /* 如果没有头像，显示默认图标 */
            .admin-avatar:empty::before {
                content: "👤";
                font-size: 20px;
                color: rgba(255, 255, 255, 0.8);
            }

            /* 主体布局 */
            .main-container {
                display: flex;
                margin-top: 60px;
                min-height: calc(100vh - 60px);
            }

            /* 侧边栏 */
            .sidebar {
                width: 260px;
                background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
                border-right: 1px solid #e9ecef;
                box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
                min-height: calc(100vh - 60px);
                position: fixed;
                left: 0;
                top: 60px;
            }

            .sidebar-header {
                padding: 20px 25px;
                border-bottom: 1px solid #e9ecef;
                background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
                position: relative;
            }

            .sidebar-title {
                font-size: 16px;
                font-weight: 600;
                color: #4CAF50;
                margin: 0;
                text-shadow: 0 1px 2px rgba(76, 175, 80, 0.1);
            }

            .sidebar-header::after {
                content: '';
                position: absolute;
                bottom: 0;
                left: 25px;
                right: 25px;
                height: 2px;
                background: linear-gradient(90deg, #4CAF50, transparent);
            }

            /* Menu控件样式 */
            .menu {
                width: 100%;
                border: none;
            }

            .menu .staticMenuStyle {
                background: white;
                border: none;
            }

            .menu .staticMenuItemStyle {
                padding: 15px 25px;
                border: none;
                border-left: 3px solid transparent;
                color: #666;
                font-size: 14px;
                transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
                position: relative;
                overflow: hidden;
                cursor: pointer;
                border-radius: 0 8px 8px 0;
                margin: 2px 0;
                background: linear-gradient(90deg, transparent 0%, transparent 100%);
            }

            .menu .staticMenuItemStyle::before {
                content: '';
                position: absolute;
                top: 0;
                left: -100%;
                width: 100%;
                height: 100%;
                background: linear-gradient(90deg, transparent, rgba(76, 175, 80, 0.1), transparent);
                transition: left 0.6s ease;
            }

            .menu .staticMenuItemStyle:hover::before {
                left: 100%;
            }

            .menu .staticHoverStyle {
                background: linear-gradient(135deg, #f8f9fa 0%, #e8f5e8 100%);
                color: #4CAF50;
                border-left-color: #4CAF50;
                transform: translateX(8px);
                box-shadow: 0 4px 15px rgba(76, 175, 80, 0.2);
                font-weight: 500;
            }

            .menu .staticSelectedStyle {
                background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%);
                color: #4CAF50;
                border-left-color: #4CAF50;
                font-weight: 600;
                transform: translateX(5px);
                box-shadow: 0 2px 10px rgba(76, 175, 80, 0.15);
            }

            .menu a {
                text-decoration: none;
                color: inherit;
                display: block;
                position: relative;
                z-index: 1;
            }

            /* 菜单项图标动画效果 */
            .menu .staticMenuItemStyle:hover {
                animation: menuItemPulse 0.6s ease-in-out;
            }

            @keyframes menuItemPulse {
                0% {
                    transform: translateX(0) scale(1);
                }

                50% {
                    transform: translateX(4px) scale(1.02);
                }

                100% {
                    transform: translateX(8px) scale(1);
                }
            }

            /* 菜单项文字效果 */
            .menu .staticMenuItemStyle:hover {
                text-shadow: 0 1px 3px rgba(76, 175, 80, 0.3);
            }

            /* 内容区域 */
            .content-area {
                flex: 1;
                margin-left: 260px;
                padding: 30px;
                background: #f5f7fa;
                min-height: calc(100vh - 60px);
            }

            .page-header {
                background: white;
                padding: 25px;
                border-radius: 10px;
                box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
                margin-bottom: 25px;
                border-left: 4px solid #4CAF50;
            }

            .page-title {
                font-size: 24px;
                color: #333;
                margin: 0 0 8px 0;
                font-weight: 600;
            }

            .page-description {
                color: #666;
                font-size: 14px;
                margin: 0;
            }

            .content-card {
                background: white;
                padding: 25px;
                border-radius: 10px;
                box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
                margin-bottom: 20px;
            }

            /* GridView 样式优化 */
            .gridview-container {
                background: white;
                border-radius: 10px;
                box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
                overflow: hidden;
                margin-top: 20px;
            }

            .gridview-header {
                background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
                padding: 20px;
                color: white;
                display: flex;
                justify-content: space-between;
                align-items: center;
            }

            .gridview-title {
                font-size: 18px;
                font-weight: 600;
                margin: 0;
            }

            .add-user-btn {
                background: rgba(255, 255, 255, 0.2);
                border: 1px solid rgba(255, 255, 255, 0.3);
                color: white;
                padding: 10px 20px;
                border-radius: 6px;
                font-size: 14px;
                cursor: pointer;
                transition: all 0.3s ease;
                text-decoration: none;
                display: inline-flex;
                align-items: center;
                gap: 8px;
            }

            .add-user-btn:hover {
                background: rgba(255, 255, 255, 0.3);
                border-color: rgba(255, 255, 255, 0.5);
                transform: translateY(-1px);
                text-decoration: none;
                color: white;
            }

            /* GridView 表格样式 */
            .styled-gridview {
                width: 100%;
                border-collapse: collapse;
                font-size: 14px;
                background: white;
            }

            .styled-gridview th {
                background: #f8f9fa;
                color: #333;
                font-weight: 600;
                padding: 15px 12px;
                text-align: left;
                border-bottom: 2px solid #e9ecef;
                font-size: 13px;
                text-transform: uppercase;
                letter-spacing: 0.5px;
            }

            .styled-gridview td {
                padding: 12px;
                border-bottom: 1px solid #e9ecef;
                vertical-align: middle;
            }

            .styled-gridview tr:hover {
                background: #f8f9fa;
            }

            .styled-gridview tr:nth-child(even) {
                background: #fdfdfd;
            }

            .styled-gridview tr:nth-child(even):hover {
                background: #f8f9fa;
            }

            /* 按钮样式优化 */
            .btn-edit {
                background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
                border: none;
                color: white;
                padding: 6px 12px;
                border-radius: 4px;
                font-size: 12px;
                cursor: pointer;
                transition: all 0.3s ease;
                margin-right: 5px;
            }

            .btn-edit:hover {
                background: linear-gradient(135deg, #138496 0%, #117a8b 100%);
                transform: translateY(-1px);
                box-shadow: 0 2px 5px rgba(23, 162, 184, 0.3);
            }

            .btn-delete {
                background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
                border: none;
                color: white;
                padding: 6px 12px;
                border-radius: 4px;
                font-size: 12px;
                cursor: pointer;
                transition: all 0.3s ease;
            }

            .btn-delete:hover {
                background: linear-gradient(135deg, #c82333 0%, #bd2130 100%);
                transform: translateY(-1px);
                box-shadow: 0 2px 5px rgba(220, 53, 69, 0.3);
            }

            .btn-update {
                background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
                border: none;
                color: white;
                padding: 6px 12px;
                border-radius: 4px;
                font-size: 12px;
                cursor: pointer;
                transition: all 0.3s ease;
                margin-right: 5px;
            }

            .btn-update:hover {
                background: linear-gradient(135deg, #20c997 0%, #1e7e34 100%);
                transform: translateY(-1px);
                box-shadow: 0 2px 5px rgba(40, 167, 69, 0.3);
            }

            .btn-cancel {
                background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
                border: none;
                color: white;
                padding: 6px 12px;
                border-radius: 4px;
                font-size: 12px;
                cursor: pointer;
                transition: all 0.3s ease;
            }

            .btn-cancel:hover {
                background: linear-gradient(135deg, #5a6268 0%, #545b62 100%);
                transform: translateY(-1px);
                box-shadow: 0 2px 5px rgba(108, 117, 125, 0.3);
            }

            /* 添加用户模态框样式 */
            .modal-overlay {
                display: none;
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                background: rgba(0, 0, 0, 0.5);
                z-index: 2000;
                justify-content: center;
                align-items: center;
            }

            .modal-content {
                background: white;
                border-radius: 10px;
                padding: 30px;
                width: 90%;
                max-width: 500px;
                max-height: 80vh;
                overflow-y: auto;
                box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
                animation: modalSlideIn 0.3s ease;
            }

            @keyframes modalSlideIn {
                from {
                    opacity: 0;
                    transform: translateY(-50px);
                }

                to {
                    opacity: 1;
                    transform: translateY(0);
                }
            }

            .modal-header {
                display: flex;
                justify-content: space-between;
                align-items: center;
                margin-bottom: 20px;
                padding-bottom: 15px;
                border-bottom: 2px solid #e9ecef;
            }

            .modal-title {
                font-size: 20px;
                font-weight: 600;
                color: #333;
                margin: 0;
            }

            .close-btn {
                background: none;
                border: none;
                font-size: 24px;
                color: #999;
                cursor: pointer;
                padding: 0;
                width: 30px;
                height: 30px;
                display: flex;
                align-items: center;
                justify-content: center;
                border-radius: 50%;
                transition: all 0.3s ease;
            }

            .close-btn:hover {
                background: #f8f9fa;
                color: #333;
            }

            .form-group {
                margin-bottom: 20px;
            }

            .form-label {
                display: block;
                margin-bottom: 8px;
                font-weight: 500;
                color: #333;
                font-size: 14px;
            }

            .form-control {
                width: 100%;
                padding: 10px 12px;
                border: 2px solid #e9ecef;
                border-radius: 6px;
                font-size: 14px;
                transition: all 0.3s ease;
                background: white;
            }

            .form-control:focus {
                outline: none;
                border-color: #4CAF50;
                box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
            }

            .form-actions {
                display: flex;
                gap: 10px;
                justify-content: flex-end;
                margin-top: 25px;
                padding-top: 20px;
                border-top: 1px solid #e9ecef;
            }

            .btn-primary {
                background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
                border: none;
                color: white;
                padding: 10px 20px;
                border-radius: 6px;
                font-size: 14px;
                cursor: pointer;
                transition: all 0.3s ease;
            }

            .btn-primary:hover {
                background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%);
                transform: translateY(-1px);
                box-shadow: 0 3px 8px rgba(76, 175, 80, 0.3);
            }

            .btn-secondary {
                background: #6c757d;
                border: none;
                color: white;
                padding: 10px 20px;
                border-radius: 6px;
                font-size: 14px;
                cursor: pointer;
                transition: all 0.3s ease;
            }

            .btn-secondary:hover {
                background: #5a6268;
                transform: translateY(-1px);
            }

            /* 响应式设计 */
            @media (max-width: 768px) {
                .sidebar {
                    width: 100%;
                    transform: translateX(-100%);
                    transition: transform 0.3s ease;
                }

                .content-area {
                    margin-left: 0;
                    padding: 20px;
                }

                .system-title {
                    font-size: 16px;
                }

                .modal-content {
                    width: 95%;
                    padding: 20px;
                }

                .styled-gridview {
                    font-size: 12px;
                }

                .styled-gridview th,
                .styled-gridview td {
                    padding: 8px 6px;
                }
            }
        </style>
    </head>

    <body>
        <form id="form1" runat="server">
            <!-- 顶部导航栏 -->
            <header class="top-header">
                <div class="logo-section">
                    <div class="logo-icon">
                        🌱
                    </div>
                    <h1 class="system-title">特色农产品销售系统</h1>
                </div>

                <div class="user-info">
                    <!-- 管理员头像 -->
                    <div class="admin-avatar">
                        <asp:Image ID="imgAdminAvatar" runat="server" CssClass="avatar-img" AlternateText="管理员头像" />
                    </div>
                    <span class="welcome-text">管理员，欢迎您</span>
                    <!-- 启用退出按钮 -->
                    <asp:LinkButton ID="lnkLogout" runat="server" CssClass="logout-btn" OnClick="lnkLogout_Click">
                        退出登录
                    </asp:LinkButton>
                </div>
            </header>

            <!-- 主体容器 -->
            <div class="main-container">
                <!-- 侧边栏 -->
                <nav class="sidebar">
                    <div class="sidebar-header">
                        <h3 class="sidebar-title">管理功能</h3>
                    </div>

                    <!-- menu控件 -->
                    <asp:menu id="navigationmenu" runat="server" cssclass="menu"
                        staticmenuitemstyle-cssclass="staticmenuitemstyle" statichoverstyle-cssclass="statichoverstyle"
                        staticselectedstyle-cssclass="staticselectedstyle" staticmenustyle-cssclass="staticmenustyle"
                        orientation="vertical" onmenuitemclick="Navigationmenu_MenuItemClick">
                        <items>
                            <asp:menuitem text="👥 管理员管理" value="0" selected="true"></asp:menuitem>
                            <asp:menuitem text="👤 用户管理" value="1"></asp:menuitem>
                            <asp:menuitem text="📂 分类管理" value="2"></asp:menuitem>
                            <asp:menuitem text="🛒 商品管理" value="3"></asp:menuitem>
                            <asp:menuitem text="📋 订单管理" value="4"></asp:menuitem>
                            <asp:menuitem text="💳 支付管理" value="5"></asp:menuitem>
                            <asp:menuitem text="📊 统计信息" value="6"></asp:menuitem>
                        </items>
                    </asp:menu>
                </nav>

                <!-- 内容区域 -->
                <main class="content-area">
                    <!-- MultiView控件 -->
                    <asp:MultiView ID="ContentMultiView" runat="server" ActiveViewIndex="0">

                        <!-- 管理员管理视图 -->
                        <asp:View ID="AdminManageView" runat="server">
                            <div class="gridview-container">
                                <div class="gridview-header">
                                    <h3 class="gridview-title">👥 管理员信息管理</h3>
                                    <button type="button" class="add-user-btn" onclick="showAddUserModal()">
                                        <span>➕</span> 添加管理员
                                    </button>
                                </div>

                                <!-- 搜索功能区域 -->
                                <div class="search-container"
                                    style="background: #f8f9fa; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #e9ecef;">
                                    <div style="display: flex; gap: 15px; align-items: center; flex-wrap: wrap;">
                                        <div style="display: flex; align-items: center; gap: 8px;">
                                            <label style="font-weight: 500; color: #495057;">管理员编号：</label>
                                            <asp:TextBox ID="txtSearchUserId" runat="server" CssClass="form-control"
                                                style="width: 120px; padding: 6px 12px; border: 1px solid #ced4da; border-radius: 4px;"
                                                placeholder="输入编号"></asp:TextBox>
                                        </div>
                                        <div style="display: flex; align-items: center; gap: 8px;">
                                            <label style="font-weight: 500; color: #495057;">管理员名字：</label>
                                            <asp:TextBox ID="txtSearchUserName" runat="server" CssClass="form-control"
                                                style="width: 150px; padding: 6px 12px; border: 1px solid #ced4da; border-radius: 4px;"
                                                placeholder="输入名字"></asp:TextBox>
                                        </div>
                                        <div style="display: flex; gap: 10px;">
                                            <asp:Button ID="btnSearch" runat="server" Text="🔍 搜索"
                                                OnClick="btnSearch_Click" CssClass="btn-search"
                                                style="background: #007bff; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: 500;" />
                                            <asp:Button ID="btnReset" runat="server" Text="🔄 重置"
                                                OnClick="btnReset_Click" CssClass="btn-reset"
                                                style="background: #6c757d; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: 500;" />
                                        </div>
                                    </div>
                                </div>

                                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                                    DataKeyNames="UserId" DataSourceID="SqlDataSource1"
                                    OnRowUpdating="GridView1_RowUpdating" OnRowDeleting="GridView1_RowDeleting"
                                    OnRowUpdated="GridView1_RowUpdated" CssClass="styled-gridview" GridLines="None"
                                    BorderStyle="None">
                                    <Columns>
                                        <asp:BoundField DataField="UserId" HeaderText="管理员编号" InsertVisible="False"
                                            ReadOnly="True" SortExpression="UserId" />
                                        <asp:BoundField DataField="UserName" HeaderText="管理员名字"
                                            SortExpression="UserName" />
                                        <asp:BoundField DataField="Password" HeaderText="密码"
                                            SortExpression="Password" />
                                        <asp:BoundField DataField="Phone" HeaderText="电话" SortExpression="Phone" />
                                        <asp:TemplateField HeaderText="头像" SortExpression="UserImagee">
                                            <EditItemTemplate>
                                                <div
                                                    style="display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px; background-color: #f8f9fa; border-radius: 8px; border: 1px solid #e9ecef;">
                                                    <!-- 当前头像预览 -->
                                                    <div style="text-align: center;">
                                                        <label
                                                            style="font-size: 12px; color: #6c757d; margin-bottom: 5px; display: block;">当前头像</label>
                                                        <asp:Image ID="PreviewImage" runat="server"
                                                            ImageUrl='<%# Eval("UserImagee") %>' Width="80px"
                                                            Height="80px"
                                                            style="border-radius: 8px; border: 2px solid #dee2e6; box-shadow: 0 2px 4px rgba(0,0,0,0.1);" />
                                                    </div>

                                                    <!-- 文件上传区域 -->
                                                    <div style="width: 100%; text-align: center;">
                                                        <label
                                                            style="font-size: 12px; color: #6c757d; margin-bottom: 5px; display: block;">选择新头像</label>
                                                        <asp:FileUpload ID="FileUpload1" runat="server"
                                                            CssClass="form-control" accept="image/*"
                                                            style="margin-bottom: 8px; font-size: 12px; padding: 6px 8px; border: 1px solid #ced4da; border-radius: 4px; background-color: white;" />
                                                        <small
                                                            style="color: #6c757d; font-size: 10px; display: block;">支持
                                                            JPG, PNG, GIF 格式，建议尺寸 200x200px</small>
                                                    </div>

                                                    <!-- 隐藏字段 -->
                                                    <asp:HiddenField ID="HiddenField1" runat="server"
                                                        Value='<%# Bind("UserImagee") %>' />
                                                </div>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <div style="text-align: center; padding: 5px;">
                                                    <asp:Image ID="Image1" runat="server"
                                                        ImageUrl='<%# Eval("UserImagee") %>' Width="60px" Height="60px"
                                                        style="border-radius: 8px; border: 1px solid #ddd; box-shadow: 0 1px 3px rgba(0,0,0,0.1);" />
                                                </div>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="Address" HeaderText="地址" SortExpression="Address" />
                                        <asp:BoundField DataField="UserType" HeaderText="用户类型"
                                            SortExpression="UserType" />
                                        <asp:TemplateField HeaderText="操作">
                                            <EditItemTemplate>
                                                <asp:Button ID="Button3" runat="server" CommandName="Update" Text="保存"
                                                    CssClass="btn-update" />
                                                &nbsp;&nbsp;
                                                <asp:Button ID="Button4" runat="server" CommandName="Cancel" Text="取消"
                                                    CssClass="btn-cancel" />
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Button ID="Button1" runat="server" CommandName="Edit" Text="编辑"
                                                    CssClass="btn-edit" />
                                                &nbsp;&nbsp;
                                                <asp:Button ID="Button2" runat="server" CommandName="Delete" Text="删除"
                                                    CssClass="btn-delete"
                                                    OnClientClick="return confirm('确定要删除这个管理员吗？');" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </div>

                            <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                                ConnectionString="<%$ ConnectionStrings:AgriculturalSalesConnectionString %>"
                                SelectCommand="SELECT * FROM [Users] WHERE [UserType] = '管理员'"
                                DeleteCommand="DELETE FROM [Users] WHERE [UserId] = @UserId"
                                InsertCommand="INSERT INTO [Users] ([UserName], [Password], [Phone], [UserImagee], [Address], [UserType]) VALUES (@UserName, @Password, @Phone, @UserImagee, @Address, @UserType)"
                                UpdateCommand="UPDATE [Users] SET [UserName] = @UserName, [Password] = @Password, [Phone] = @Phone, [UserImagee] = @UserImagee, [Address] = @Address, [UserType] = @UserType WHERE [UserId] = @UserId"
                                ProviderName="<%$ ConnectionStrings:AgriculturalSalesConnectionString.ProviderName %>">
                                <DeleteParameters>
                                    <asp:Parameter Name="UserId" Type="Int32" />
                                </DeleteParameters>
                                <InsertParameters>
                                    <asp:Parameter Name="UserName" Type="String" />
                                    <asp:Parameter Name="Password" Type="String" />
                                    <asp:Parameter Name="Phone" Type="String" />
                                    <asp:Parameter Name="UserImagee" Type="String" />
                                    <asp:Parameter Name="Address" Type="String" />
                                    <asp:Parameter Name="UserType" Type="String" />
                                </InsertParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="UserName" Type="String" />
                                    <asp:Parameter Name="Password" Type="String" />
                                    <asp:Parameter Name="Phone" Type="String" />
                                    <asp:SessionParameter Name="UserImagee" SessionField="p" Type="String" />
                                    <asp:Parameter Name="Address" Type="String" />
                                    <asp:Parameter Name="UserType" Type="String" />
                                    <asp:Parameter Name="UserId" Type="Int32" />
                                </UpdateParameters>
                            </asp:SqlDataSource>
                        </asp:View>

                        <!-- 用户管理视图 -->
                        <asp:View ID="UserManageView" runat="server">
                            <div class="gridview-container">
                                <div class="gridview-header">
                                    <h3 class="gridview-title">👤 用户信息管理</h3>
                                    <button type="button" class="add-user-btn" onclick="showAddNormalUserModal()">
                                        <span>➕</span> 添加用户
                                    </button>
                                </div>

                                <!-- 搜索功能区域 -->
                                <div class="search-container"
                                    style="background: #f8f9fa; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #e9ecef;">
                                    <div style="display: flex; gap: 15px; align-items: center; flex-wrap: wrap;">
                                        <div style="display: flex; align-items: center; gap: 8px;">
                                            <label style="font-weight: 500; color: #495057;">搜索类型：</label>
                                            <asp:DropDownList ID="ddlSearchType" runat="server" CssClass="form-control"
                                                style="width: 120px; padding: 6px 12px; border: 1px solid #ced4da; border-radius: 4px;">
                                                <asp:ListItem Value="UserId" Text="用户编号"></asp:ListItem>
                                                <asp:ListItem Value="UserName" Text="用户名字"></asp:ListItem>
                                                <asp:ListItem Value="Address" Text="地址"></asp:ListItem>
                                            </asp:DropDownList>
                                        </div>
                                        <div style="display: flex; align-items: center; gap: 8px;">
                                            <label style="font-weight: 500; color: #495057;">搜索内容：</label>
                                            <asp:TextBox ID="txtSearchContent" runat="server" CssClass="form-control"
                                                style="width: 200px; padding: 6px 12px; border: 1px solid #ced4da; border-radius: 4px;"
                                                placeholder="请输入搜索内容"></asp:TextBox>
                                        </div>
                                        <div style="display: flex; gap: 10px;">
                                            <asp:Button ID="btnSearchNormalUser" runat="server" Text="🔍 搜索"
                                                OnClick="btnSearchNormalUser_Click" CssClass="btn-search"
                                                style="background: #007bff; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: 500;" />
                                            <asp:Button ID="btnResetNormalUser" runat="server" Text="🔄 重置"
                                                OnClick="btnResetNormalUser_Click" CssClass="btn-reset"
                                                style="background: #6c757d; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: 500;" />
                                        </div>
                                    </div>
                                </div>

                                <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
                                    DataKeyNames="UserId" DataSourceID="SqlDataSource2"
                                    OnRowUpdating="GridView2_RowUpdating" OnRowDeleting="GridView2_RowDeleting"
                                    OnRowUpdated="GridView2_RowUpdated" OnRowDeleted="GridView2_RowDeleted"
                                    CssClass="styled-gridview" GridLines="None" BorderStyle="None">
                                    <Columns>
                                        <asp:BoundField DataField="UserId" HeaderText="用户编号" InsertVisible="False"
                                            ReadOnly="True" SortExpression="UserId" />
                                        <asp:BoundField DataField="UserName" HeaderText="用户名字"
                                            SortExpression="UserName" />
                                        <asp:BoundField DataField="Password" HeaderText="密码"
                                            SortExpression="Password" />
                                        <asp:BoundField DataField="Phone" HeaderText="电话" SortExpression="Phone" />
                                        <asp:TemplateField HeaderText="头像" SortExpression="UserImagee">
                                            <EditItemTemplate>
                                                <div
                                                    style="display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px; background-color: #f8f9fa; border-radius: 8px; border: 1px solid #e9ecef;">
                                                    <!-- 当前头像预览 -->
                                                    <div style="text-align: center;">
                                                        <label
                                                            style="font-size: 12px; color: #6c757d; margin-bottom: 5px; display: block;">当前头像</label>
                                                        <asp:Image ID="PreviewImage2" runat="server"
                                                            ImageUrl='<%# Eval("UserImagee") %>' Width="80px"
                                                            Height="80px"
                                                            style="border-radius: 8px; border: 2px solid #dee2e6; box-shadow: 0 2px 4px rgba(0,0,0,0.1);" />
                                                    </div>

                                                    <!-- 文件上传区域 -->
                                                    <div style="width: 100%; text-align: center;">
                                                        <label
                                                            style="font-size: 12px; color: #6c757d; margin-bottom: 5px; display: block;">选择新头像</label>
                                                        <asp:FileUpload ID="FileUpload2" runat="server"
                                                            CssClass="form-control" accept="image/*"
                                                            style="margin-bottom: 8px; font-size: 12px; padding: 6px 8px; border: 1px solid #ced4da; border-radius: 4px; background-color: white;" />
                                                        <small
                                                            style="color: #6c757d; font-size: 10px; display: block;">支持
                                                            JPG, PNG, GIF 格式，建议尺寸 200x200px</small>
                                                    </div>

                                                    <!-- 隐藏字段 -->
                                                    <asp:HiddenField ID="HiddenField2" runat="server"
                                                        Value='<%# Bind("UserImagee") %>' />
                                                </div>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <div style="text-align: center; padding: 5px;">
                                                    <asp:Image ID="Image2" runat="server"
                                                        ImageUrl='<%# Eval("UserImagee") %>' Width="60px" Height="60px"
                                                        style="border-radius: 8px; border: 1px solid #ddd; box-shadow: 0 1px 3px rgba(0,0,0,0.1);" />
                                                </div>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="Address" HeaderText="地址" SortExpression="Address" />
                                        <asp:BoundField DataField="UserType" HeaderText="用户类型"
                                            SortExpression="UserType" />
                                        <asp:TemplateField HeaderText="操作">
                                            <EditItemTemplate>
                                                <asp:Button ID="Button5" runat="server" CommandName="Update" Text="保存"
                                                    CssClass="btn-update" />
                                                &nbsp;&nbsp;
                                                <asp:Button ID="Button6" runat="server" CommandName="Cancel" Text="取消"
                                                    CssClass="btn-cancel" />
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Button ID="Button7" runat="server" CommandName="Edit" Text="编辑"
                                                    CssClass="btn-edit" />
                                                &nbsp;&nbsp;
                                                <asp:Button ID="Button8" runat="server" CommandName="Delete" Text="删除"
                                                    CssClass="btn-delete"
                                                    OnClientClick="return confirm('确定要删除这个用户吗？');" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </div>

                            <asp:SqlDataSource ID="SqlDataSource2" runat="server"
                                ConnectionString="<%$ ConnectionStrings:AgriculturalSalesConnectionString %>"
                                SelectCommand="SELECT * FROM [Users] WHERE [UserType] = '普通用户'"
                                DeleteCommand="DELETE FROM [Users] WHERE [UserId] = @UserId"
                                InsertCommand="INSERT INTO [Users] ([UserName], [Password], [Phone], [UserImagee], [Address], [UserType]) VALUES (@UserName, @Password, @Phone, @UserImagee, @Address, @UserType)"
                                UpdateCommand="UPDATE [Users] SET [UserName] = @UserName, [Password] = @Password, [Phone] = @Phone, [UserImagee] = @UserImagee, [Address] = @Address, [UserType] = @UserType WHERE [UserId] = @UserId"
                                ProviderName="<%$ ConnectionStrings:AgriculturalSalesConnectionString.ProviderName %>">
                                <DeleteParameters>
                                    <asp:Parameter Name="UserId" Type="Int32" />
                                </DeleteParameters>
                                <InsertParameters>
                                    <asp:Parameter Name="UserName" Type="String" />
                                    <asp:Parameter Name="Password" Type="String" />
                                    <asp:Parameter Name="Phone" Type="String" />
                                    <asp:Parameter Name="UserImagee" Type="String" />
                                    <asp:Parameter Name="Address" Type="String" />
                                    <asp:Parameter Name="UserType" Type="String" />
                                </InsertParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="UserName" Type="String" />
                                    <asp:Parameter Name="Password" Type="String" />
                                    <asp:Parameter Name="Phone" Type="String" />
                                    <asp:SessionParameter Name="UserImagee" SessionField="p2" Type="String" />
                                    <asp:Parameter Name="Address" Type="String" />
                                    <asp:Parameter Name="UserType" Type="String" />
                                    <asp:Parameter Name="UserId" Type="Int32" />
                                </UpdateParameters>
                            </asp:SqlDataSource>
                        </asp:View>

                        <!-- 分类管理视图 -->
                        <asp:View ID="CategoryManageView" runat="server">
                            <div class="gridview-container">
                                <div class="gridview-header">
                                    <h3 class="gridview-title">📂 分类信息管理</h3>
                                    <button type="button" class="add-user-btn" onclick="showAddCategoryModal()">
                                        <span>➕</span> 添加分类
                                    </button>
                                </div>

                                <!-- 搜索功能区域 -->
                                <div class="search-container"
                                    style="background: #f8f9fa; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #e9ecef;">
                                    <div style="display: flex; gap: 15px; align-items: center; flex-wrap: wrap;">
                                        <div style="display: flex; align-items: center; gap: 8px;">
                                            <label style="font-weight: 500; color: #495057;">搜索类型：</label>
                                            <asp:DropDownList ID="ddlCategorySearchType" runat="server"
                                                CssClass="form-control"
                                                style="width: 120px; padding: 6px 12px; border: 1px solid #ced4da; border-radius: 4px;">
                                                <asp:ListItem Value="CategoryId" Text="分类编号"></asp:ListItem>
                                                <asp:ListItem Value="CategoryName" Text="分类名称"></asp:ListItem>
                                            </asp:DropDownList>
                                        </div>
                                        <div style="display: flex; align-items: center; gap: 8px;">
                                            <label style="font-weight: 500; color: #495057;">搜索内容：</label>
                                            <asp:TextBox ID="txtCategorySearchContent" runat="server"
                                                CssClass="form-control"
                                                style="width: 200px; padding: 6px 12px; border: 1px solid #ced4da; border-radius: 4px;"
                                                placeholder="请输入搜索内容"></asp:TextBox>
                                        </div>
                                        <div style="display: flex; gap: 10px;">
                                            <asp:Button ID="btnSearchCategory" runat="server" Text="🔍 搜索"
                                                OnClick="btnSearchCategory_Click" CssClass="btn-search"
                                                style="background: #007bff; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: 500;" />
                                            <asp:Button ID="btnResetCategory" runat="server" Text="🔄 重置"
                                                OnClick="btnResetCategory_Click" CssClass="btn-reset"
                                                style="background: #6c757d; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: 500;" />
                                        </div>
                                    </div>
                                </div>

                                <asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False"
                                    DataKeyNames="CategoryId" DataSourceID="SqlDataSource3"
                                    OnRowUpdating="GridView3_RowUpdating" OnRowDeleting="GridView3_RowDeleting"
                                    OnRowUpdated="GridView3_RowUpdated" OnRowDeleted="GridView3_RowDeleted"
                                    CssClass="styled-gridview" GridLines="None" BorderStyle="None">
                                    <Columns>
                                        <asp:BoundField DataField="CategoryId" HeaderText="分类编号" InsertVisible="False"
                                            ReadOnly="True" SortExpression="CategoryId" />
                                        <asp:BoundField DataField="CategoryName" HeaderText="分类名称"
                                            SortExpression="CategoryName" />
                                        <asp:TemplateField HeaderText="操作">
                                            <EditItemTemplate>
                                                <asp:Button ID="Button9" runat="server" CommandName="Update" Text="保存"
                                                    CssClass="btn-update" />
                                                &nbsp;&nbsp;
                                                <asp:Button ID="Button10" runat="server" CommandName="Cancel" Text="取消"
                                                    CssClass="btn-cancel" />
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Button ID="Button11" runat="server" CommandName="Edit" Text="编辑"
                                                    CssClass="btn-edit" />
                                                &nbsp;&nbsp;
                                                <asp:Button ID="Button12" runat="server" CommandName="Delete" Text="删除"
                                                    CssClass="btn-delete"
                                                    OnClientClick="return confirm('确定要删除这个分类吗？删除后相关商品也会受到影响！');" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </div>

                            <asp:SqlDataSource ID="SqlDataSource3" runat="server"
                                ConnectionString="<%$ ConnectionStrings:AgriculturalSalesConnectionString %>"
                                SelectCommand="SELECT * FROM [ProductCategory]"
                                DeleteCommand="DELETE FROM [ProductCategory] WHERE [CategoryId] = @CategoryId"
                                InsertCommand="INSERT INTO [ProductCategory] ([CategoryName]) VALUES (@CategoryName)"
                                UpdateCommand="UPDATE [ProductCategory] SET [CategoryName] = @CategoryName WHERE [CategoryId] = @CategoryId"
                                ProviderName="<%$ ConnectionStrings:AgriculturalSalesConnectionString.ProviderName %>">
                                <DeleteParameters>
                                    <asp:Parameter Name="CategoryId" Type="Int32" />
                                </DeleteParameters>
                                <InsertParameters>
                                    <asp:Parameter Name="CategoryName" Type="String" />
                                </InsertParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="CategoryName" Type="String" />
                                    <asp:Parameter Name="CategoryId" Type="Int32" />
                                </UpdateParameters>
                            </asp:SqlDataSource>
                        </asp:View>

                        <!-- 商品管理视图 -->
                        <asp:View ID="ProductManageView" runat="server">
                            <div class="gridview-container">
                                <div class="gridview-header">
                                    <h3 class="gridview-title">🛍️ 商品信息管理</h3>
                                    <button type="button" class="add-user-btn" onclick="showAddProductModal()">
                                        <span>➕</span> 添加商品
                                    </button>
                                </div>

                                <!-- 搜索功能区域 -->
                                <div class="search-container"
                                    style="background: #f8f9fa; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #e9ecef;">
                                    <div style="display: flex; gap: 15px; align-items: center; flex-wrap: wrap;">
                                        <div style="display: flex; align-items: center; gap: 8px;">
                                            <label style="font-weight: 500; color: #495057;">搜索类型：</label>
                                            <asp:DropDownList ID="ddlProductSearchType" runat="server"
                                                CssClass="form-control"
                                                style="width: 120px; padding: 6px 12px; border: 1px solid #ced4da; border-radius: 4px;">
                                                <asp:ListItem Value="ProductId" Text="商品编号"></asp:ListItem>
                                                <asp:ListItem Value="Name" Text="商品名称"></asp:ListItem>
                                                <asp:ListItem Value="CategoryId" Text="分类编号"></asp:ListItem>
                                                <asp:ListItem Value="Origin" Text="产地"></asp:ListItem>
                                                <asp:ListItem Value="UserId" Text="管理员编号"></asp:ListItem>
                                            </asp:DropDownList>
                                        </div>
                                        <div style="display: flex; align-items: center; gap: 8px;">
                                            <label style="font-weight: 500; color: #495057;">搜索内容：</label>
                                            <asp:TextBox ID="txtProductSearchContent" runat="server"
                                                CssClass="form-control"
                                                style="width: 200px; padding: 6px 12px; border: 1px solid #ced4da; border-radius: 4px;"
                                                placeholder="请输入搜索内容"></asp:TextBox>
                                        </div>
                                        <div style="display: flex; gap: 10px;">
                                            <asp:Button ID="btnSearchProduct" runat="server" Text="🔍 搜索"
                                                OnClick="btnSearchProduct_Click" CssClass="btn-search"
                                                style="background: #007bff; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: 500;" />
                                            <asp:Button ID="btnResetProduct" runat="server" Text="🔄 重置"
                                                OnClick="btnResetProduct_Click" CssClass="btn-reset"
                                                style="background: #6c757d; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: 500;" />
                                        </div>
                                    </div>
                                </div>

                                <asp:GridView ID="GridView4" runat="server" AutoGenerateColumns="False"
                                    DataKeyNames="ProductId" DataSourceID="SqlDataSource4"
                                    OnRowUpdating="GridView4_RowUpdating" OnRowDeleting="GridView4_RowDeleting"
                                    OnRowUpdated="GridView4_RowUpdated" OnRowDeleted="GridView4_RowDeleted"
                                    CssClass="styled-gridview" GridLines="None" BorderStyle="None">
                                    <Columns>
                                        <asp:BoundField DataField="ProductId" HeaderText="商品编号" InsertVisible="False"
                                            ReadOnly="True" SortExpression="ProductId" />
                                        <asp:TemplateField HeaderText="分类" SortExpression="CategoryId">
                                            <EditItemTemplate>
                                                <asp:DropDownList ID="ddlCategoryEdit" runat="server"
                                                    DataSourceID="SqlDataSourceCategories" DataTextField="CategoryName"
                                                    DataValueField="CategoryId"
                                                    SelectedValue='<%# Bind("CategoryId") %>'
                                                    style="width: 120px; padding: 4px 8px; border: 1px solid #ced4da; border-radius: 4px;">
                                                </asp:DropDownList>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("CategoryId") %>'>
                                                </asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="UserId" HeaderText="管理员编号" SortExpression="UserId" />
                                        <asp:TemplateField HeaderText="商品名称" SortExpression="Name">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="txtNameEdit" runat="server" Text='<%# Bind("Name") %>'
                                                    style="width: 150px; padding: 4px 8px; border: 1px solid #ced4da; border-radius: 4px;">
                                                </asp:TextBox>
                                                <asp:RequiredFieldValidator ID="rfvName" runat="server"
                                                    ControlToValidate="txtNameEdit" ErrorMessage="*" ForeColor="Red">
                                                </asp:RequiredFieldValidator>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("Name") %>'>
                                                </asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="产地" SortExpression="Origin">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="txtOriginEdit" runat="server"
                                                    Text='<%# Bind("Origin") %>'
                                                    style="width: 120px; padding: 4px 8px; border: 1px solid #ced4da; border-radius: 4px;">
                                                </asp:TextBox>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("Origin") %>'>
                                                </asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="价格" SortExpression="Price">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="txtPriceEdit" runat="server"
                                                    Text='<%# Bind("Price") %>'
                                                    style="width: 80px; padding: 4px 8px; border: 1px solid #ced4da; border-radius: 4px;">
                                                </asp:TextBox>
                                                <asp:RequiredFieldValidator ID="rfvPrice" runat="server"
                                                    ControlToValidate="txtPriceEdit" ErrorMessage="*" ForeColor="Red">
                                                </asp:RequiredFieldValidator>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label4" runat="server"
                                                    Text='<%# Bind("Price", "{0:C}") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="库存" SortExpression="Inventory">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="txtInventoryEdit" runat="server"
                                                    Text='<%# Bind("Inventory") %>'
                                                    style="width: 70px; padding: 4px 8px; border: 1px solid #ced4da; border-radius: 4px;">
                                                </asp:TextBox>
                                                <asp:RequiredFieldValidator ID="rfvInventory" runat="server"
                                                    ControlToValidate="txtInventoryEdit" ErrorMessage="*"
                                                    ForeColor="Red"></asp:RequiredFieldValidator>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label5" runat="server" Text='<%# Bind("Inventory") %>'>
                                                </asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="单位" SortExpression="Unit">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="txtUnitEdit" runat="server" Text='<%# Bind("Unit") %>'
                                                    style="width: 60px; padding: 4px 8px; border: 1px solid #ced4da; border-radius: 4px;">
                                                </asp:TextBox>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label6" runat="server" Text='<%# Bind("Unit") %>'>
                                                </asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="描述" SortExpression="Descr">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="txtDescrEdit" runat="server"
                                                    Text='<%# Bind("Descr") %>' TextMode="MultiLine" Rows="2"
                                                    style="width: 150px; padding: 4px 8px; border: 1px solid #ced4da; border-radius: 4px; resize: vertical;">
                                                </asp:TextBox>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label7" runat="server" Text='<%# Bind("Descr") %>'
                                                    style="max-width: 150px; word-wrap: break-word; display: inline-block;">
                                                </asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="商品图片" SortExpression="ImageUrl">
                                            <EditItemTemplate>
                                                <div
                                                    style="display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px; background-color: #f8f9fa; border-radius: 8px; border: 1px solid #e9ecef;">
                                                    <!-- 当前图片预览 -->
                                                    <div style="text-align: center;">
                                                        <label
                                                            style="font-size: 12px; color: #6c757d; margin-bottom: 5px; display: block;">当前图片</label>
                                                        <asp:Image ID="PreviewImage4" runat="server"
                                                            ImageUrl='<%# GetProductImageUrl(Eval("ImageUrl")) %>'
                                                            Width="80px" Height="80px"
                                                            style="border-radius: 8px; border: 2px solid #dee2e6; box-shadow: 0 2px 4px rgba(0,0,0,0.1);"
                                                            onerror="this.src='~/Image/default-product.jpg';" />
                                                    </div>

                                                    <!-- 文件上传区域 -->
                                                    <div style="width: 100%; text-align: center;">
                                                        <label
                                                            style="font-size: 12px; color: #6c757d; margin-bottom: 5px; display: block;">选择新图片</label>
                                                        <asp:FileUpload ID="FileUpload4" runat="server"
                                                            CssClass="form-control" accept="image/*"
                                                            style="margin-bottom: 8px; font-size: 12px; padding: 6px 8px; border: 1px solid #ced4da; border-radius: 4px; background-color: white;" />
                                                        <small
                                                            style="color: #6c757d; font-size: 10px; display: block;">支持
                                                            JPG, PNG, GIF 格式，建议尺寸 200x200px</small>
                                                    </div>

                                                    <!-- 隐藏字段 -->
                                                    <asp:HiddenField ID="HiddenField4" runat="server"
                                                        Value='<%# Bind("ImageUrl") %>' />
                                                </div>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <div style="text-align: center; padding: 5px;">
                                                    <asp:Image ID="Image4" runat="server"
                                                        ImageUrl='<%# GetProductImageUrl(Eval("ImageUrl")) %>'
                                                        Width="60px" Height="60px"
                                                        style="border-radius: 8px; border: 1px solid #ddd; box-shadow: 0 1px 3px rgba(0,0,0,0.1);"
                                                        onerror="this.src='~/Image/default-product.jpg';" />
                                                </div>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="操作">
                                            <EditItemTemplate>
                                                <asp:Button ID="Button9" runat="server" CommandName="Update" Text="保存"
                                                    CssClass="btn-update" />
                                                &nbsp;&nbsp;
                                                <asp:Button ID="Button10" runat="server" CommandName="Cancel" Text="取消"
                                                    CssClass="btn-cancel" />
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Button ID="Button11" runat="server" CommandName="Edit" Text="编辑"
                                                    CssClass="btn-edit" />
                                                &nbsp;&nbsp;
                                                <asp:Button ID="Button12" runat="server" CommandName="Delete" Text="删除"
                                                    CssClass="btn-delete"
                                                    OnClientClick="return confirm('确定要删除这个商品吗？');" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </div>

                            <!-- 分类数据源 -->
                            <asp:SqlDataSource ID="SqlDataSourceCategories" runat="server"
                                ConnectionString="<%$ ConnectionStrings:AgriculturalSalesConnectionString %>"
                                SelectCommand="SELECT [CategoryId], [CategoryName] FROM [ProductCategory] ORDER BY [CategoryName]">
                            </asp:SqlDataSource>

                            <!-- 商品数据源 -->
                            <asp:SqlDataSource ID="SqlDataSource4" runat="server"
                                ConnectionString="<%$ ConnectionStrings:AgriculturalSalesConnectionString %>"
                                SelectCommand="SELECT * FROM [Product]"
                                DeleteCommand="DELETE FROM [Product] WHERE [ProductId] = @ProductId"
                                InsertCommand="INSERT INTO [Product] ([CategoryId], [UserId], [Name], [Origin], [Price], [Inventory], [Unit], [Descr], [ImageUrl]) VALUES (@CategoryId, @UserId, @Name, @Origin, @Price, @Inventory, @Unit, @Descr, @ImageUrl)"
                                UpdateCommand="UPDATE [Product] SET [CategoryId] = @CategoryId, [UserId] = @UserId, [Name] = @Name, [Origin] = @Origin, [Price] = @Price, [Inventory] = @Inventory, [Unit] = @Unit, [Descr] = @Descr, [ImageUrl] = @ImageUrl WHERE [ProductId] = @ProductId">
                                <DeleteParameters>
                                    <asp:Parameter Name="ProductId" Type="Int32" />
                                </DeleteParameters>
                                <InsertParameters>
                                    <asp:Parameter Name="CategoryId" Type="Int32" />
                                    <asp:Parameter Name="UserId" Type="Int32" />
                                    <asp:Parameter Name="Name" Type="String" />
                                    <asp:Parameter Name="Origin" Type="String" />
                                    <asp:Parameter Name="Price" Type="Decimal" />
                                    <asp:Parameter Name="Inventory" Type="Int32" />
                                    <asp:Parameter Name="Unit" Type="String" />
                                    <asp:Parameter Name="Descr" Type="String" />
                                    <asp:Parameter Name="ImageUrl" Type="String" />
                                </InsertParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="CategoryId" Type="Int32" />
                                    <asp:Parameter Name="UserId" Type="Int32" />
                                    <asp:Parameter Name="Name" Type="String" />
                                    <asp:Parameter Name="Origin" Type="String" />
                                    <asp:Parameter Name="Price" Type="Decimal" />
                                    <asp:Parameter Name="Inventory" Type="Int32" />
                                    <asp:Parameter Name="Unit" Type="String" />
                                    <asp:Parameter Name="Descr" Type="String" />
                                    <asp:SessionParameter Name="ImageUrl" SessionField="p4" Type="String" />
                                    <asp:Parameter Name="ProductId" Type="Int32" />
                                </UpdateParameters>
                            </asp:SqlDataSource>
                        </asp:View>

                        <!-- 订单管理视图 -->
                        <asp:View ID="OrderManageView" runat="server">
                            <div class="gridview-container">
                                <div class="gridview-header">
                                    <h3 class="gridview-title">📦 订单信息管理</h3>
                                </div>

                                <!-- 搜索功能区域 -->
                                <div class="search-container"
                                    style="background: #f8f9fa; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #e9ecef;">
                                    <div style="display: flex; gap: 15px; align-items: center; flex-wrap: wrap;">
                                        <div style="display: flex; align-items: center; gap: 8px;">
                                            <label style="font-weight: 500; color: #495057;">搜索类型：</label>
                                            <asp:DropDownList ID="ddlOrderSearchType" runat="server"
                                                CssClass="form-control"
                                                style="width: 120px; padding: 6px 12px; border: 1px solid #ced4da; border-radius: 4px;">
                                                <asp:ListItem Value="OrderId" Text="订单编号"></asp:ListItem>
                                                <asp:ListItem Value="UserId" Text="用户编号"></asp:ListItem>
                                                <asp:ListItem Value="OrderState" Text="订单状态"></asp:ListItem>
                                                <asp:ListItem Value="ContactPhone" Text="联系电话"></asp:ListItem>
                                            </asp:DropDownList>
                                        </div>
                                        <div style="display: flex; align-items: center; gap: 8px;">
                                            <label style="font-weight: 500; color: #495057;">搜索内容：</label>
                                            <asp:TextBox ID="txtOrderSearchContent" runat="server"
                                                CssClass="form-control"
                                                style="width: 200px; padding: 6px 12px; border: 1px solid #ced4da; border-radius: 4px;"
                                                placeholder="请输入搜索内容"></asp:TextBox>
                                        </div>
                                        <div style="display: flex; gap: 10px;">
                                            <asp:Button ID="btnSearchOrder" runat="server" Text="🔍 搜索"
                                                OnClick="btnSearchOrder_Click" CssClass="btn-search"
                                                style="background: #007bff; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: 500;" />
                                            <asp:Button ID="btnResetOrder" runat="server" Text="🔄 重置"
                                                OnClick="btnResetOrder_Click" CssClass="btn-reset"
                                                style="background: #6c757d; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: 500;" />
                                        </div>
                                    </div>
                                </div>

                                <asp:GridView ID="GridView5" runat="server" AutoGenerateColumns="False"
                                    DataKeyNames="OrderId" DataSourceID="SqlDataSource5"
                                    OnRowUpdating="GridView5_RowUpdating" OnRowDeleting="GridView5_RowDeleting"
                                    OnRowUpdated="GridView5_RowUpdated" OnRowDeleted="GridView5_RowDeleted"
                                    CssClass="styled-gridview" GridLines="None" BorderStyle="None">
                                    <Columns>
                                        <asp:TemplateField HeaderText="交易信息">
                                            <ItemTemplate>
                                                <asp:Button ID="btnShowPayment" runat="server" Text="💳 交易信息"
                                                    CommandName="ShowPayment" CommandArgument='<%# Eval("OrderId") %>'
                                                    OnClick="btnShowPayment_Click"
                                                    style="background: #28a745; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 12px;" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="OrderId" HeaderText="订单编号" InsertVisible="False"
                                            ReadOnly="True" SortExpression="OrderId" />
                                        <asp:BoundField DataField="UserId" HeaderText="用户编号" SortExpression="UserId" />
                                        <asp:BoundField DataField="OrderNum" HeaderText="订单数量"
                                            SortExpression="OrderNum" />
                                        <asp:TemplateField HeaderText="订单状态" SortExpression="OrderState">
                                            <EditItemTemplate>
                                                <asp:DropDownList ID="ddlOrderStateEdit" runat="server"
                                                    SelectedValue='<%# Bind("OrderState") %>'>
                                                    <asp:ListItem Value="待支付" Text="待支付"></asp:ListItem>
                                                    <asp:ListItem Value="已支付" Text="已支付"></asp:ListItem>
                                                    <asp:ListItem Value="已发货" Text="已发货"></asp:ListItem>
                                                    <asp:ListItem Value="已完成" Text="已完成"></asp:ListItem>
                                                    <asp:ListItem Value="已取消" Text="已取消"></asp:ListItem>
                                                </asp:DropDownList>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("OrderState") %>'>
                                                </asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="TotalAmout" HeaderText="总金额"
                                            SortExpression="TotalAmout" />
                                        <asp:BoundField DataField="DeliveryAddr" HeaderText="发货地址"
                                            SortExpression="DeliveryAddr" />
                                        <asp:BoundField DataField="ContactPhone" HeaderText="联系电话"
                                            SortExpression="ContactPhone" />
                                        <asp:BoundField DataField="UpdateAt" HeaderText="更新时间" SortExpression="UpdateAt"
                                            ReadOnly="True" />
                                        <asp:TemplateField HeaderText="操作">
                                            <EditItemTemplate>
                                                <asp:Button ID="Button1" runat="server" CommandName="Update" Text="保存"
                                                    CssClass="btn-update" />
                                                &nbsp;&nbsp;
                                                <asp:Button ID="Button2" runat="server" CommandName="Cancel" Text="取消"
                                                    CssClass="btn-cancel" />
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Button ID="Button3" runat="server" CommandName="Edit" Text="编辑"
                                                    CssClass="btn-edit" />
                                                &nbsp;&nbsp;
                                                <asp:Button ID="Button4" runat="server" CommandName="Delete" Text="删除"
                                                    CssClass="btn-delete"
                                                    OnClientClick="return confirm('确定要删除这个订单吗？删除订单将同时删除对应的支付记录！');" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </div>

                            <!-- 支付信息FormView，居中显示 -->
                            <div style="display: flex; justify-content: center; margin-top: 30px;">
                                <div
                                    style="background: #f8f9fa; padding: 20px; border-radius: 8px; border: 1px solid #e9ecef; min-width: 400px;">
                                    <h4 style="text-align: center; color: #495057; margin-bottom: 20px;">💳 支付信息详情</h4>
                                    <asp:FormView ID="FormView1" runat="server" DataKeyNames="PayId"
                                        DataSourceID="SqlDataSource6" style="width: 100%;">
                                        <EditItemTemplate>
                                            <div
                                                style="display: grid; grid-template-columns: 120px 1fr; gap: 15px; align-items: center;">
                                                <label>支付编号：</label>
                                                <asp:Label ID="PayIdLabel1" runat="server" Text='<%# Eval("PayId") %>'
                                                    style="font-weight: bold; color: #007bff;" />

                                                <label>订单编号：</label>
                                                <asp:TextBox ID="OrderIdTextBox" runat="server"
                                                    Text='<%# Bind("OrderId") %>' ReadOnly="true"
                                                    style="background: #e9ecef;" />

                                                <label>支付方式：</label>
                                                <asp:DropDownList ID="ddlPayMethodEdit" runat="server"
                                                    SelectedValue='<%# Bind("PayMethod") %>'>
                                                    <asp:ListItem Value="微信支付" Text="微信支付"></asp:ListItem>
                                                    <asp:ListItem Value="支付宝" Text="支付宝"></asp:ListItem>
                                                    <asp:ListItem Value="银行卡" Text="银行卡"></asp:ListItem>
                                                    <asp:ListItem Value="货到付款" Text="货到付款"></asp:ListItem>
                                                </asp:DropDownList>

                                                <label>支付金额：</label>
                                                <asp:TextBox ID="PayAmoutTextBox" runat="server"
                                                    Text='<%# Bind("PayAmout") %>' />

                                                <label>支付状态：</label>
                                                <asp:DropDownList ID="ddlPayStateEdit" runat="server"
                                                    SelectedValue='<%# Bind("PayState") %>'>
                                                    <asp:ListItem Value="未支付" Text="未支付"></asp:ListItem>
                                                    <asp:ListItem Value="支付成功" Text="支付成功"></asp:ListItem>
                                                    <asp:ListItem Value="支付失败" Text="支付失败"></asp:ListItem>
                                                    <asp:ListItem Value="已退款" Text="已退款"></asp:ListItem>
                                                </asp:DropDownList>

                                                <label>支付时间：</label>
                                                <asp:TextBox ID="PayTimeTextBox" runat="server"
                                                    Text='<%# Bind("PayTime") %>' ReadOnly="true"
                                                    style="background: #e9ecef;" />

                                                <div style="grid-column: span 2; text-align: center; margin-top: 15px;">
                                                    <asp:LinkButton ID="UpdateButton" runat="server"
                                                        CausesValidation="True" CommandName="Update" Text="更新"
                                                        style="background: #007bff; color: white; padding: 8px 16px; border-radius: 4px; text-decoration: none; margin-right: 10px;" />
                                                    <asp:LinkButton ID="UpdateCancelButton" runat="server"
                                                        CausesValidation="False" CommandName="Cancel" Text="取消"
                                                        style="background: #6c757d; color: white; padding: 8px 16px; border-radius: 4px; text-decoration: none;" />
                                                </div>
                                            </div>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <div
                                                style="display: grid; grid-template-columns: 120px 1fr; gap: 15px; align-items: center;">
                                                <label>支付编号：</label>
                                                <asp:Label ID="PayIdLabel" runat="server" Text='<%# Eval("PayId") %>'
                                                    style="font-weight: bold; color: #007bff;" />

                                                <label>订单编号：</label>
                                                <asp:Label ID="OrderIdLabel" runat="server"
                                                    Text='<%# Bind("OrderId") %>'
                                                    style="font-weight: bold; color: #28a745;" />

                                                <label>支付方式：</label>
                                                <asp:Label ID="PayMethodLabel" runat="server"
                                                    Text='<%# Bind("PayMethod") %>' />

                                                <label>支付金额：</label>
                                                <asp:Label ID="PayAmoutLabel" runat="server"
                                                    Text='<%# Bind("PayAmout") %>'
                                                    style="color: #dc3545; font-weight: bold;" />

                                                <label>支付状态：</label>
                                                <asp:Label ID="PayStateLabel" runat="server"
                                                    Text='<%# Bind("PayState") %>' />

                                                <label>支付时间：</label>
                                                <asp:Label ID="PayTimeLabel" runat="server"
                                                    Text='<%# Bind("PayTime") %>' />

                                                <div style="grid-column: span 2; text-align: center; margin-top: 15px;">
                                                    <asp:LinkButton ID="EditButton" runat="server"
                                                        CausesValidation="False" CommandName="Edit" Text="编辑支付信息"
                                                        style="background: #ffc107; color: #212529; padding: 8px 16px; border-radius: 4px; text-decoration: none;" />
                                                </div>
                                            </div>
                                        </ItemTemplate>
                                        <EmptyDataTemplate>
                                            <div style="text-align: center; color: #6c757d; padding: 20px;">
                                                <p>📋 暂无支付信息</p>
                                                <p>请先点击订单列表中的"交易信息"按钮查看对应的支付详情</p>
                                            </div>
                                        </EmptyDataTemplate>
                                    </asp:FormView>
                                </div>
                            </div>

                            <asp:SqlDataSource ID="SqlDataSource5" runat="server"
                                ConnectionString="<%$ ConnectionStrings:AgriculturalSalesConnectionString %>"
                                SelectCommand="SELECT * FROM [Order]"
                                DeleteCommand="DELETE FROM [Payment] WHERE [OrderId] = @OrderId; DELETE FROM [OrderProduct] WHERE [OrderId] = @OrderId; DELETE FROM [Order] WHERE [OrderId] = @OrderId"
                                UpdateCommand="UPDATE [Order] SET [UserId] = @UserId, [OrderNum] = @OrderNum, [OrderState] = @OrderState, [TotalAmout] = @TotalAmout, [DeliveryAddr] = @DeliveryAddr, [ContactPhone] = @ContactPhone, [UpdateAt] = GETDATE() WHERE [OrderId] = @OrderId">
                                <DeleteParameters>
                                    <asp:Parameter Name="OrderId" Type="Int32" />
                                </DeleteParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="UserId" Type="Int32" />
                                    <asp:Parameter Name="OrderNum" Type="Int32" />
                                    <asp:Parameter Name="OrderState" Type="String" />
                                    <asp:Parameter Name="TotalAmout" Type="Decimal" />
                                    <asp:Parameter Name="DeliveryAddr" Type="String" />
                                    <asp:Parameter Name="ContactPhone" Type="String" />
                                    <asp:Parameter Name="OrderId" Type="Int32" />
                                </UpdateParameters>
                            </asp:SqlDataSource>

                            <asp:SqlDataSource ID="SqlDataSource6" runat="server"
                                ConnectionString="<%$ ConnectionStrings:AgriculturalSalesConnectionString %>"
                                SelectCommand="SELECT * FROM [Payment] WHERE [OrderId] = @OrderId"
                                UpdateCommand="UPDATE [Payment] SET [PayMethod] = @PayMethod, [PayAmout] = @PayAmout, [PayState] = @PayState WHERE [PayId] = @PayId">
                                <SelectParameters>
                                    <asp:Parameter Name="OrderId" Type="Int32" DefaultValue="-1" />
                                </SelectParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="PayMethod" Type="String" />
                                    <asp:Parameter Name="PayAmout" Type="Decimal" />
                                    <asp:Parameter Name="PayState" Type="String" />
                                    <asp:Parameter Name="PayId" Type="Int32" />
                                </UpdateParameters>
                            </asp:SqlDataSource>
                        </asp:View>

                        <!-- 支付管理视图 -->
                        <asp:View ID="PaymentManageView" runat="server">
                            <div class="gridview-container">
                                <div class="gridview-header">
                                    <h3 class="gridview-title">💳 支付信息管理</h3>
                                </div>

                                <!-- 搜索功能区域 -->
                                <div class="search-container"
                                    style="background: #f8f9fa; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #e9ecef;">
                                    <div style="display: flex; gap: 15px; align-items: center; flex-wrap: wrap;">
                                        <div style="display: flex; align-items: center; gap: 8px;">
                                            <label style="font-weight: 500; color: #495057;">搜索类型：</label>
                                            <asp:DropDownList ID="ddlPaymentSearchType" runat="server"
                                                CssClass="form-control"
                                                style="width: 120px; padding: 6px 12px; border: 1px solid #ced4da; border-radius: 4px;">
                                                <asp:ListItem Value="PayId" Text="支付编号"></asp:ListItem>
                                                <asp:ListItem Value="OrderId" Text="订单编号"></asp:ListItem>
                                                <asp:ListItem Value="PayMethod" Text="支付方式"></asp:ListItem>
                                                <asp:ListItem Value="PayState" Text="支付状态"></asp:ListItem>
                                            </asp:DropDownList>
                                        </div>
                                        <div style="display: flex; align-items: center; gap: 8px;">
                                            <label style="font-weight: 500; color: #495057;">搜索内容：</label>
                                            <asp:TextBox ID="txtPaymentSearchContent" runat="server"
                                                CssClass="form-control"
                                                style="width: 200px; padding: 6px 12px; border: 1px solid #ced4da; border-radius: 4px;"
                                                placeholder="请输入搜索内容"></asp:TextBox>
                                        </div>
                                        <div style="display: flex; gap: 10px;">
                                            <asp:Button ID="btnSearchPayment" runat="server" Text="🔍 搜索"
                                                OnClick="btnSearchPayment_Click" CssClass="btn-search"
                                                style="background: #007bff; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: 500;" />
                                            <asp:Button ID="btnResetPayment" runat="server" Text="🔄 重置"
                                                OnClick="btnResetPayment_Click" CssClass="btn-reset"
                                                style="background: #6c757d; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: 500;" />
                                        </div>
                                    </div>
                                </div>

                                <!-- GridView -->
                                <asp:GridView ID="GridView6" runat="server" AutoGenerateColumns="False"
                                    DataKeyNames="PayId" DataSourceID="SqlDataSource7" CssClass="styled-gridview"
                                    HeaderStyle-BackColor="#f8f9fa" HeaderStyle-ForeColor="#333"
                                    HeaderStyle-Font-Bold="true" RowStyle-BackColor="White"
                                    AlternatingRowStyle-BackColor="#f8f9fa" BorderStyle="None" GridLines="Horizontal"
                                    Width="100%">
                                    <Columns>
                                        <asp:BoundField DataField="PayId" HeaderText="支付编号" InsertVisible="False"
                                            ReadOnly="True" SortExpression="PayId" ItemStyle-Width="80px"
                                            ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" />
                                        <asp:BoundField DataField="OrderId" HeaderText="订单编号" SortExpression="OrderId"
                                            ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Center"
                                            HeaderStyle-HorizontalAlign="Center" />
                                        <asp:BoundField DataField="PayMethod" HeaderText="支付方式"
                                            SortExpression="PayMethod" ItemStyle-Width="100px"
                                            ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" />
                                        <asp:BoundField DataField="PayAmout" HeaderText="支付金额" SortExpression="PayAmout"
                                            DataFormatString="{0:C2}" ItemStyle-Width="100px"
                                            ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Center" />
                                        <asp:TemplateField HeaderText="支付状态" SortExpression="PayState"
                                            ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center"
                                            HeaderStyle-HorizontalAlign="Center">
                                            <ItemTemplate>
                                                <span style='<%# GetPaymentStatusStyle(Eval("PayState").ToString()) %>'>
                                                    <%# Eval("PayState") %>
                                                </span>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="PayTime" HeaderText="支付时间" SortExpression="PayTime"
                                            DataFormatString="{0:yyyy-MM-dd HH:mm:ss}" ItemStyle-Width="150px"
                                            ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" />
                                    </Columns>
                                    <HeaderStyle BackColor="#f8f9fa" ForeColor="#333" Font-Bold="True" Height="40px" />
                                    <RowStyle BackColor="White" Height="35px" />
                                    <AlternatingRowStyle BackColor="#f8f9fa" />
                                    <PagerStyle BackColor="#f8f9fa" ForeColor="#333" HorizontalAlign="Center" />
                                </asp:GridView>

                                <!-- 支付数据源 -->
                                <asp:SqlDataSource ID="SqlDataSource7" runat="server"
                                    ConnectionString="<%$ ConnectionStrings:AgriculturalSalesConnectionString %>"
                                    SelectCommand="SELECT * FROM [Payment] ORDER BY [PayTime] DESC">
                                </asp:SqlDataSource>
                            </div>
                        </asp:View>

                        <!-- 统计信息视图 -->
                        <asp:View ID="StatisticsView" runat="server">
                            <div class="page-header">
                                <h2 class="page-title">📊 统计信息</h2>
                                <p class="page-description">系统运营数据统计概览</p>
                            </div>

                            <!-- 统计卡片容器 -->
                            <div
                                style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 25px; margin-bottom: 30px;">

                                <!-- 网站访问次数卡片 -->
                                <div
                                    style="background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%); color: white; padding: 25px; border-radius: 15px; box-shadow: 0 8px 25px rgba(116, 185, 255, 0.3); position: relative; overflow: hidden;">
                                    <div
                                        style="position: absolute; top: -20px; right: -20px; font-size: 80px; opacity: 0.1;">
                                        🌐</div>
                                    <div style="position: relative; z-index: 1;">
                                        <h3
                                            style="margin: 0 0 10px 0; font-size: 16px; font-weight: 500; opacity: 0.9;">
                                            网站访问次数</h3>
                                        <div style="font-size: 36px; font-weight: 700; margin: 10px 0;">
                                            <asp:Label ID="lblVisitCount" runat="server" Text="1"></asp:Label>
                                        </div>
                                        <p style="margin: 0; font-size: 14px; opacity: 0.8;">当前访客数</p>
                                    </div>
                                </div>

                                <!-- 在售农产品卡片 -->
                                <div
                                    style="background: linear-gradient(135deg, #00b894 0%, #00a085 100%); color: white; padding: 25px; border-radius: 15px; box-shadow: 0 8px 25px rgba(0, 184, 148, 0.3); position: relative; overflow: hidden;">
                                    <div
                                        style="position: absolute; top: -20px; right: -20px; font-size: 80px; opacity: 0.1;">
                                        🌱</div>
                                    <div style="position: relative; z-index: 1;">
                                        <h3
                                            style="margin: 0 0 10px 0; font-size: 16px; font-weight: 500; opacity: 0.9;">
                                            在售农产品</h3>
                                        <div style="font-size: 36px; font-weight: 700; margin: 10px 0;">
                                            <asp:Label ID="lblProductCount" runat="server" Text="5"></asp:Label>
                                        </div>
                                        <p style="margin: 0; font-size: 14px; opacity: 0.8;">可售状态书籍</p>
                                    </div>
                                </div>

                                <!-- 注册用户卡片 -->
                                <div onclick="window.open('Register.aspx', '_blank')"
                                    style="background: linear-gradient(135deg, #fd79a8 0%, #e84393 100%); color: white; padding: 25px; border-radius: 15px; box-shadow: 0 8px 25px rgba(253, 121, 168, 0.3); position: relative; overflow: hidden; cursor: pointer; transition: all 0.3s ease;"
                                    onmouseover="this.style.transform='translateY(-3px)'; this.style.boxShadow='0 12px 30px rgba(253, 121, 168, 0.4)'"
                                    onmouseout="this.style.transform='translateY(0)'; this.style.boxShadow='0 8px 25px rgba(253, 121, 168, 0.3)'">
                                    <div
                                        style="position: absolute; top: -20px; right: -20px; font-size: 80px; opacity: 0.1;">
                                        👤</div>
                                    <div style="position: relative; z-index: 1;">
                                        <h3
                                            style="margin: 0 0 10px 0; font-size: 16px; font-weight: 500; opacity: 0.9;">
                                            注册用户</h3>
                                        <div style="font-size: 36px; font-weight: 700; margin: 10px 0;">
                                            <asp:Label ID="lblUserCount" runat="server" Text="6"></asp:Label>
                                        </div>
                                        <p style="margin: 0; font-size: 14px; opacity: 0.8;">总注册用户数 - 点击查看注册页面</p>
                                    </div>
                                </div>

                                <!-- 成功交易卡片 -->
                                <div
                                    style="background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%); color: white; padding: 25px; border-radius: 15px; box-shadow: 0 8px 25px rgba(162, 155, 254, 0.3); position: relative; overflow: hidden;">
                                    <div
                                        style="position: absolute; top: -20px; right: -20px; font-size: 80px; opacity: 0.1;">
                                        💰</div>
                                    <div style="position: relative; z-index: 1;">
                                        <h3
                                            style="margin: 0 0 10px 0; font-size: 16px; font-weight: 500; opacity: 0.9;">
                                            成功交易</h3>
                                        <div style="font-size: 36px; font-weight: 700; margin: 10px 0;">
                                            <asp:Label ID="lblSuccessOrderCount" runat="server" Text="0"></asp:Label>
                                        </div>
                                        <p style="margin: 0; font-size: 14px; opacity: 0.8;">已完成交易数</p>
                                    </div>
                                </div>
                            </div>

                            <!-- 详细统计信息 -->
                            <div class="content-card">
                                <h3
                                    style="color: #333; margin-bottom: 20px; font-size: 18px; border-bottom: 2px solid #4CAF50; padding-bottom: 10px;">
                                    📈 详细统计</h3>

                                <div
                                    style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 25px;">
                                    <div
                                        style="text-align: center; padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #74b9ff;">
                                        <div
                                            style="font-size: 24px; font-weight: 600; color: #74b9ff; margin-bottom: 5px;">
                                            <asp:Label ID="lblTotalSales" runat="server" Text="¥0.00"></asp:Label>
                                        </div>
                                        <div style="color: #666; font-size: 14px;">总销售金额</div>
                                    </div>

                                    <div
                                        style="text-align: center; padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #00b894;">
                                        <div
                                            style="font-size: 24px; font-weight: 600; color: #00b894; margin-bottom: 5px;">
                                            <asp:Label ID="lblPendingOrders" runat="server" Text="0"></asp:Label>
                                        </div>
                                        <div style="color: #666; font-size: 14px;">待处理订单</div>
                                    </div>

                                    <div
                                        style="text-align: center; padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #fd79a8;">
                                        <div
                                            style="font-size: 24px; font-weight: 600; color: #fd79a8; margin-bottom: 5px;">
                                            <asp:Label ID="lblLowStockProducts" runat="server" Text="0"></asp:Label>
                                        </div>
                                        <div style="color: #666; font-size: 14px;">库存不足商品</div>
                                    </div>

                                    <div
                                        style="text-align: center; padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #a29bfe;">
                                        <div
                                            style="font-size: 24px; font-weight: 600; color: #a29bfe; margin-bottom: 5px;">
                                            <asp:Label ID="lblTotalCategories" runat="server" Text="0"></asp:Label>
                                        </div>
                                        <div style="color: #666; font-size: 14px;">商品分类数</div>
                                    </div>
                                </div>

                                <!-- 刷新统计按钮 -->
                                <div style="text-align: center; margin-top: 25px;">
                                    <asp:Button ID="btnRefreshStats" runat="server" Text="🔄 刷新统计"
                                        CssClass="btn-primary" OnClick="btnRefreshStats_Click"
                                        style="background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%); border: none; color: white; padding: 12px 25px; border-radius: 8px; font-size: 14px; cursor: pointer; transition: all 0.3s ease;" />
                                </div>

                                <div style="margin-top: 20px; text-align: center; color: #666; font-size: 13px;">
                                    <span>最后更新时间：</span>
                                    <asp:Label ID="lblLastUpdateTime" runat="server" Text="2025-06-26 16:57:15">
                                    </asp:Label>
                                </div>
                            </div>

                            <!-- 数据源 -->
                            <asp:SqlDataSource ID="SqlDataSourceStats" runat="server"
                                ConnectionString="<%$ ConnectionStrings:AgriculturalSalesConnectionString %>">
                            </asp:SqlDataSource>
                        </asp:View>

                    </asp:MultiView>
                </main>
            </div>

            <!-- 添加用户模态框 -->
            <div id="addUserModal" class="modal-overlay">
                <div class="modal-content">
                    <div class="modal-header">
                        <h3 class="modal-title">添加新管理员</h3>
                        <button type="button" class="close-btn" onclick="hideAddUserModal()">&times;</button>
                    </div>

                    <div class="form-group">
                        <label class="form-label">用户名</label>
                        <asp:TextBox ID="txtUserName" runat="server" CssClass="form-control" placeholder="请输入用户名">
                        </asp:TextBox>
                    </div>

                    <div class="form-group">
                        <label class="form-label">密码</label>
                        <asp:TextBox ID="txtPassword" runat="server" CssClass="form-control" TextMode="Password"
                            placeholder="请输入密码"></asp:TextBox>
                    </div>

                    <div class="form-group">
                        <label class="form-label">电话</label>
                        <asp:TextBox ID="txtPhone" runat="server" CssClass="form-control" placeholder="请输入电话号码">
                        </asp:TextBox>
                    </div>

                    <div class="form-group">
                        <label class="form-label">头像</label>
                        <asp:FileUpload ID="fuUserImage" runat="server" CssClass="form-control" />
                    </div>

                    <div class="form-group">
                        <label class="form-label">地址</label>
                        <asp:TextBox ID="txtAddress" runat="server" CssClass="form-control" TextMode="MultiLine"
                            Rows="3" placeholder="请输入地址"></asp:TextBox>
                    </div>

                    <div class="form-actions">
                        <asp:Button ID="btnAddUser" runat="server" Text="添加管理员" CssClass="btn-primary"
                            OnClick="btnAddUser_Click" />
                        <button type="button" class="btn-secondary" onclick="hideAddUserModal()">取消</button>
                    </div>
                </div>
            </div>

            <!-- 添加普通用户模态框 -->
            <div id="addNormalUserModal" class="modal-overlay">
                <div class="modal-content">
                    <div class="modal-header">
                        <h3 class="modal-title">👤 添加新用户</h3>
                        <button type="button" class="close-btn" onclick="hideAddNormalUserModal()">&times;</button>
                    </div>

                    <div class="form-group">
                        <label class="form-label">用户名</label>
                        <asp:TextBox ID="txtNormalUserName" runat="server" CssClass="form-control" placeholder="请输入用户名">
                        </asp:TextBox>
                        <asp:RequiredFieldValidator ID="rfvNormalUserName" runat="server"
                            ControlToValidate="txtNormalUserName" ErrorMessage="用户名不能为空" CssClass="text-danger"
                            ValidationGroup="AddNormalUser" Display="Dynamic" />
                    </div>

                    <div class="form-group">
                        <label class="form-label">密码</label>
                        <asp:TextBox ID="txtNormalPassword" runat="server" CssClass="form-control" TextMode="Password"
                            placeholder="请输入密码"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="rfvNormalPassword" runat="server"
                            ControlToValidate="txtNormalPassword" ErrorMessage="密码不能为空" CssClass="text-danger"
                            ValidationGroup="AddNormalUser" Display="Dynamic" />
                    </div>

                    <div class="form-group">
                        <label class="form-label">电话</label>
                        <asp:TextBox ID="txtNormalPhone" runat="server" CssClass="form-control" placeholder="请输入电话号码">
                        </asp:TextBox>
                        <asp:RegularExpressionValidator ID="revNormalPhone" runat="server"
                            ControlToValidate="txtNormalPhone" ErrorMessage="请输入正确的电话号码格式"
                            ValidationExpression="^[1][3-9]\d{9}$" CssClass="text-danger"
                            ValidationGroup="AddNormalUser" Display="Dynamic" />
                    </div>

                    <div class="form-group">
                        <label class="form-label">头像</label>
                        <asp:FileUpload ID="fuNormalUserImage" runat="server" CssClass="form-control"
                            accept="image/*" />
                        <small class="form-text text-muted">支持 JPG, PNG, GIF 格式，建议尺寸 200x200px</small>
                    </div>

                    <div class="form-group">
                        <label class="form-label">地址</label>
                        <asp:TextBox ID="txtNormalAddress" runat="server" CssClass="form-control" TextMode="MultiLine"
                            Rows="3" placeholder="请输入地址"></asp:TextBox>
                    </div>

                    <div class="form-actions">
                        <asp:Button ID="btnAddNormalUser" runat="server" Text="✅ 添加用户" CssClass="btn-primary"
                            OnClick="btnAddNormalUser_Click" ValidationGroup="AddNormalUser" />
                        <button type="button" class="btn-secondary" onclick="hideAddNormalUserModal()">❌ 取消</button>
                    </div>
                </div>
            </div>

            <!-- 添加分类模态框 -->
            <div id="addCategoryModal" class="modal"
                style="display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5);">
                <div class="modal-content"
                    style="background-color: #fefefe; margin: 5% auto; padding: 30px; border-radius: 12px; width: 90%; max-width: 500px; box-shadow: 0 8px 32px rgba(0,0,0,0.3); position: relative;">
                    <div class="modal-header"
                        style="border-bottom: 2px solid #e9ecef; padding-bottom: 15px; margin-bottom: 25px;">
                        <h2 style="color: #2c3e50; margin: 0; font-size: 24px; font-weight: 600;">📂 添加新分类</h2>
                        <span class="close" onclick="hideAddCategoryModal()"
                            style="position: absolute; right: 20px; top: 20px; font-size: 28px; font-weight: bold; color: #aaa; cursor: pointer; transition: color 0.3s;">&times;</span>
                    </div>

                    <div class="form-group" style="margin-bottom: 20px;">
                        <label style="display: block; margin-bottom: 8px; font-weight: 600; color: #495057;">分类名称 <span
                                style="color: #dc3545;">*</span></label>
                        <asp:TextBox ID="txtCategoryName" runat="server" CssClass="form-control"
                            style="width: 100%; padding: 12px 15px; border: 2px solid #e9ecef; border-radius: 8px; font-size: 14px; transition: border-color 0.3s;"
                            placeholder="请输入分类名称"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="rfvCategoryName" runat="server"
                            ControlToValidate="txtCategoryName" ErrorMessage="分类名称不能为空" ValidationGroup="AddCategory"
                            style="color: #dc3545; font-size: 12px; margin-top: 5px; display: block;">
                        </asp:RequiredFieldValidator>
                    </div>

                    <div class="modal-footer"
                        style="border-top: 2px solid #e9ecef; padding-top: 20px; text-align: right;">
                        <asp:Button ID="btnAddCategory" runat="server" Text="✅ 添加分类" OnClick="btnAddCategory_Click"
                            ValidationGroup="AddCategory" CssClass="btn-primary"
                            style="background: linear-gradient(135deg, #007bff, #0056b3); color: white; border: none; padding: 12px 24px; border-radius: 8px; cursor: pointer; font-weight: 600; margin-right: 10px; transition: all 0.3s;" />
                        <button type="button" onclick="hideAddCategoryModal()"
                            style="background: #6c757d; color: white; border: none; padding: 12px 24px; border-radius: 8px; cursor: pointer; font-weight: 600; transition: all 0.3s;">❌
                            取消</button>
                    </div>
                </div>
            </div>

            <!-- 添加商品模态框 -->
            <div id="addProductModal" class="modal"
                style="display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5);">
                <div class="modal-content"
                    style="background-color: #fefefe; margin: 2% auto; padding: 30px; border-radius: 12px; width: 90%; max-width: 600px; box-shadow: 0 8px 32px rgba(0,0,0,0.3); position: relative; max-height: 90vh; overflow-y: auto;">
                    <div class="modal-header"
                        style="border-bottom: 2px solid #e9ecef; padding-bottom: 15px; margin-bottom: 25px;">
                        <h2 style="color: #2c3e50; margin: 0; font-size: 24px; font-weight: 600;">➕ 添加新商品</h2>
                        <span class="close" onclick="hideAddProductModal()"
                            style="position: absolute; right: 20px; top: 20px; font-size: 28px; font-weight: bold; color: #aaa; cursor: pointer; transition: color 0.3s;">&times;</span>
                    </div>

                    <div class="modal-body">
                        <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 15px;">
                            <div class="form-group">
                                <label
                                    style="display: block; margin-bottom: 8px; font-weight: 600; color: #495057;">商品分类：</label>
                                <asp:DropDownList ID="ddlProductCategory" runat="server"
                                    DataSourceID="SqlDataSourceCategories" DataTextField="CategoryName"
                                    DataValueField="CategoryId" CssClass="form-control"
                                    style="width: 100%; padding: 8px 12px; border: 1px solid #ced4da; border-radius: 4px;">
                                </asp:DropDownList>
                            </div>
                            <div class="form-group">
                                <label
                                    style="display: block; margin-bottom: 8px; font-weight: 600; color: #495057;">商品名称：</label>
                                <asp:TextBox ID="txtProductName" runat="server" CssClass="form-control"
                                    style="width: 100%; padding: 8px 12px; border: 1px solid #ced4da; border-radius: 4px;"
                                    placeholder="请输入商品名称"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfvProductName" runat="server"
                                    ControlToValidate="txtProductName" ErrorMessage="商品名称不能为空" ForeColor="Red"
                                    Display="Dynamic" ValidationGroup="AddProduct"></asp:RequiredFieldValidator>
                            </div>
                        </div>

                        <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 15px;">
                            <div class="form-group">
                                <label
                                    style="display: block; margin-bottom: 8px; font-weight: 600; color: #495057;">产地：</label>
                                <asp:TextBox ID="txtProductOrigin" runat="server" CssClass="form-control"
                                    style="width: 100%; padding: 8px 12px; border: 1px solid #ced4da; border-radius: 4px;"
                                    placeholder="请输入产地"></asp:TextBox>
                            </div>
                            <div class="form-group">
                                <label
                                    style="display: block; margin-bottom: 8px; font-weight: 600; color: #495057;">价格：</label>
                                <asp:TextBox ID="txtProductPrice" runat="server" CssClass="form-control"
                                    style="width: 100%; padding: 8px 12px; border: 1px solid #ced4da; border-radius: 4px;"
                                    placeholder="请输入价格"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfvProductPrice" runat="server"
                                    ControlToValidate="txtProductPrice" ErrorMessage="价格不能为空" ForeColor="Red"
                                    Display="Dynamic" ValidationGroup="AddProduct"></asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="revProductPrice" runat="server"
                                    ControlToValidate="txtProductPrice" ErrorMessage="请输入有效的价格"
                                    ValidationExpression="^\d+(\.\d{1,2})?$" ForeColor="Red" Display="Dynamic"
                                    ValidationGroup="AddProduct"></asp:RegularExpressionValidator>
                            </div>
                        </div>

                        <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 15px;">
                            <div class="form-group">
                                <label
                                    style="display: block; margin-bottom: 8px; font-weight: 600; color: #495057;">库存数量：</label>
                                <asp:TextBox ID="txtProductInventory" runat="server" CssClass="form-control"
                                    style="width: 100%; padding: 8px 12px; border: 1px solid #ced4da; border-radius: 4px;"
                                    placeholder="请输入库存数量"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfvProductInventory" runat="server"
                                    ControlToValidate="txtProductInventory" ErrorMessage="库存数量不能为空" ForeColor="Red"
                                    Display="Dynamic" ValidationGroup="AddProduct"></asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="revProductInventory" runat="server"
                                    ControlToValidate="txtProductInventory" ErrorMessage="请输入有效的数量"
                                    ValidationExpression="^\d+$" ForeColor="Red" Display="Dynamic"
                                    ValidationGroup="AddProduct"></asp:RegularExpressionValidator>
                            </div>
                            <div class="form-group">
                                <label
                                    style="display: block; margin-bottom: 8px; font-weight: 600; color: #495057;">销售单位：</label>
                                <asp:TextBox ID="txtProductUnit" runat="server" CssClass="form-control"
                                    style="width: 100%; padding: 8px 12px; border: 1px solid #ced4da; border-radius: 4px;"
                                    placeholder="如：斤、公斤、箱等"></asp:TextBox>
                            </div>
                        </div>

                        <div class="form-group" style="margin-bottom: 15px;">
                            <label
                                style="display: block; margin-bottom: 8px; font-weight: 600; color: #495057;">商品描述：</label>
                            <asp:TextBox ID="txtProductDescr" runat="server" CssClass="form-control"
                                TextMode="MultiLine" Rows="3"
                                style="width: 100%; padding: 8px 12px; border: 1px solid #ced4da; border-radius: 4px; resize: vertical;"
                                placeholder="请输入商品描述"></asp:TextBox>
                        </div>

                        <div class="form-group" style="margin-bottom: 15px;">
                            <label
                                style="display: block; margin-bottom: 8px; font-weight: 600; color: #495057;">商品图片：</label>
                            <asp:FileUpload ID="fuProductImage" runat="server" CssClass="form-control" accept="image/*"
                                style="width: 100%; padding: 8px 12px; border: 1px solid #ced4da; border-radius: 4px;" />
                            <small style="color: #6c757d; font-size: 12px; margin-top: 5px; display: block;">支持 JPG,
                                PNG, GIF 格式，建议尺寸 400x400px</small>
                        </div>
                    </div>

                    <div class="modal-footer"
                        style="border-top: 2px solid #e9ecef; padding-top: 20px; text-align: right;">
                        <asp:Button ID="btnAddProduct" runat="server" Text="✅ 添加商品" OnClick="btnAddProduct_Click"
                            ValidationGroup="AddProduct" CssClass="btn-primary"
                            style="background: linear-gradient(135deg, #28a745, #20c997); color: white; border: none; padding: 12px 24px; border-radius: 8px; cursor: pointer; font-weight: 600; margin-right: 10px; transition: all 0.3s;" />
                        <button type="button" onclick="hideAddProductModal()"
                            style="background: #6c757d; color: white; border: none; padding: 12px 24px; border-radius: 8px; cursor: pointer; font-weight: 600; transition: all 0.3s;">❌
                            取消</button>
                    </div>
                </div>
            </div>

            <script type="text/javascript">
                function showAddUserModal() {
                    document.getElementById('addUserModal').style.display = 'flex';
                }

                function hideAddUserModal() {
                    document.getElementById('addUserModal').style.display = 'none';
                    // 清空表单
                    document.getElementById('<%= txtUserName.ClientID %>').value = '';
                    document.getElementById('<%= txtPassword.ClientID %>').value = '';
                    document.getElementById('<%= txtPhone.ClientID %>').value = '';
                    document.getElementById('<%= txtAddress.ClientID %>').value = '';
                    document.getElementById('<%= fuUserImage.ClientID %>').value = '';
                }

                function showAddNormalUserModal() {
                    document.getElementById('addNormalUserModal').style.display = 'flex';
                }

                function hideAddNormalUserModal() {
                    document.getElementById('addNormalUserModal').style.display = 'none';
                    // 清空表单
                    document.getElementById('<%= txtNormalUserName.ClientID %>').value = '';
                    document.getElementById('<%= txtNormalPassword.ClientID %>').value = '';
                    document.getElementById('<%= txtNormalPhone.ClientID %>').value = '';
                    document.getElementById('<%= txtNormalAddress.ClientID %>').value = '';
                    document.getElementById('<%= fuNormalUserImage.ClientID %>').value = '';
                }

                function showAddCategoryModal() {
                    document.getElementById('addCategoryModal').style.display = 'block';
                    document.getElementById('<%= txtCategoryName.ClientID %>').focus();
                }

                function hideAddCategoryModal() {
                    document.getElementById('addCategoryModal').style.display = 'none';
                    // 清空表单
                    document.getElementById('<%= txtCategoryName.ClientID %>').value = '';
                }

                // 显示添加商品模态框
                function showAddProductModal() {
                    document.getElementById('addProductModal').style.display = 'block';
                }

                // 隐藏添加商品模态框
                function hideAddProductModal() {
                    document.getElementById('addProductModal').style.display = 'none';
                    // 清空表单
                    document.getElementById('<%= txtProductName.ClientID %>').value = '';
                    document.getElementById('<%= txtProductOrigin.ClientID %>').value = '';
                    document.getElementById('<%= txtProductPrice.ClientID %>').value = '';
                    document.getElementById('<%= txtProductInventory.ClientID %>').value = '';
                    document.getElementById('<%= txtProductUnit.ClientID %>').value = '';
                    document.getElementById('<%= txtProductDescr.ClientID %>').value = '';
                    document.getElementById('<%= ddlProductCategory.ClientID %>').selectedIndex = 0;
                }

                // 点击模态框外部关闭
                document.getElementById('addUserModal').addEventListener('click', function (e) {
                    if (e.target === this) {
                        hideAddUserModal();
                    }
                });

                document.getElementById('addNormalUserModal').addEventListener('click', function (e) {
                    if (e.target === this) {
                        hideAddNormalUserModal();
                    }
                });

                // 点击模态框外部关闭
                window.onclick = function (event) {
                    var categoryModal = document.getElementById('addCategoryModal');
                    var productModal = document.getElementById('addProductModal');
                    if (event.target == categoryModal) {
                        hideAddCategoryModal();
                    }
                    if (event.target == productModal) {
                        hideAddProductModal();
                    }
                }
            </script>
        </form>
    </body>

    </html>